package qfedu.dao;

import qfedu.model.Contractor;
import qfedu.model.Developer;
import qfedu.model.Project;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface ProjectDao {

    @Results(id = "projectMap",value = {
            @Result(column = "pid",property ="pid"),
            @Result(column = "pname",property ="pname"),
            @Result(column = "starttime",property ="starttime"),
            @Result(column = "endtime",property ="endtime"),
            @Result(column = "did",property ="did"),
            @Result(column = "cid",property ="cid"),
            @Result(column = "updatetime",property = "updatetime"),
            @Result(column = "did",property = "developer",javaType = Developer.class,
                    one = @One(select = "com.qfedu.dao.DeveloperDao.findDeveByDid",fetchType = FetchType.DEFAULT)
            ),
            @Result(column = "cid",property = "contractor",javaType = Contractor.class,
                    one = @One(select = "com.qfedu.dao.StageDao.findStagesByPid",fetchType = FetchType.DEFAULT)
            ),
            @Result(column = "pid",property = "stages",
                    many = @Many(select = "com.qfedu.dao.StageDao.findStagesByPid",fetchType = FetchType.DEFAULT)
            ),
            @Result(column = "pid",property = "branches",
                    many = @Many(select = "com.qfedu.dao.BranchDao.findBranchesByPid",fetchType = FetchType.DEFAULT)
            )
    })
    @Select("select * from project where status=1")
    List<Project> findProjects();




}
